package com.example.mybatisplusdemo.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mybatisplusdemo.model.domain.Product;
import com.example.mybatisplusdemo.mapper.ProductMapper;
import com.example.mybatisplusdemo.model.dto.PageDTO;
import com.example.mybatisplusdemo.service.IProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>
 * 存储商品详情 服务实现类
 * </p>
 *
 * @author lqj
 * @since 2025-06-24
 */
@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {

    private ProductMapper productMapper;

    public ProductServiceImpl(ProductMapper productMapper) {
        this.productMapper = productMapper;
    }

    @Override
    public Page<Product> pageList(Product product, PageDTO pageDTO) {
        Page<Product> page = new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize());
        page = productMapper.pageList(page,product);
        return page;
    }

    @Override
    public int logicDeleteById(Long id) {
        return productMapper.logicDeleteById(id);
    }

    @Override
    public Page<Product> pageListWithSort(PageDTO pageDTO) {
        Page<Product> page = new Page<>(pageDTO.getPageNo(), pageDTO.getPageSize());
        return productMapper.pageListWithSort(page, pageDTO);
    }


}
